rectorParser = $rectorParser; $this->nodeScopeAndMetadataDecorator = $nodeScopeAndMetadataDecorator; $this->currentFileProvider = $currentFileProvider; $this->dynamicSourceLocatorProvider = $dynamicSourceLocatorProvider; } public function parseFilePathToFile(string $filePath) : File { // needed for PHPStan reflection, as it caches the last processed file $this->dynamicSourceLocatorProvider->setFilePath($filePath); $fileContent = FileSystem::read($filePath); $file = new File($filePath, $fileContent); $stmts = $this->rectorParser->parseString($fileContent); $stmts = $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile($filePath, $stmts); $file->hydrateStmtsAndTokens($stmts, $stmts, []); $this->currentFileProvider->setFile($file); return $file; } /** * @return Node[] */ public function parseFileToDecoratedNodes(string $filePath) : array { // needed for PHPStan reflection, as it caches the last processed file $this->dynamicSourceLocatorProvider->setFilePath($filePath); $fileContent = FileSystem::read($filePath); $stmts = $this->rectorParser->parseString($fileContent); $file = new File($filePath, $fileContent); $stmts = $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile($filePath, $stmts); $file->hydrateStmtsAndTokens($stmts, $stmts, []); $this->currentFileProvider->setFile($file); return $stmts; } }